//
//  HomeWebViewViewController.m
//  ZJControlsClass
//
//  Created by mac on 2024/11/29.
//

#import "HomeWebViewViewController.h"
#import "HomeShowInfoModel.h"
#import "HomeNetWorking.h"

@interface HomeWebViewViewController ()

@property (nonatomic,strong) HomeShowNewsInfoNetWorking * manager;
@property (nonatomic,strong) NSMutableDictionary * paramer;
@property (nonatomic,strong) UILabel * titleLabel;
@property (nonatomic,strong) UIImageView * iconImg;
@property (nonatomic,strong) UILabel * companyLabel;
@property (nonatomic,strong) UILabel * timeLabel;
@property (nonatomic,strong) UITextView * textView;


@end

@implementation HomeWebViewViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"通知详情";
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self loadNet];
    
    [self.view addSubview:self.titleLabel];
    [self.view addSubview:self.iconImg];
    [self.view addSubview:self.companyLabel];
    [self.view addSubview:self.timeLabel];
    [self.view addSubview:self.textView];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).with.offset(StatusBarHeight);
        make.left.right.equalTo(self.view);
    }];
    
    
    [self.iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).with.offset(ALIGN_WIDTH_PT(15));
        make.top.equalTo(self.titleLabel.mas_bottom).with.offset(ALIGN_HEIGHT_PT(10));
        make.size.equalTo(@(CGSizeMake(ALIGN_WIDTH_PT(30), ALIGN_WIDTH_PT(30))));
    }];
    
    [self.companyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.iconImg.mas_top);
        make.left.equalTo(self.iconImg.mas_right).with.offset(ALIGN_WIDTH_PT(8));
        make.right.equalTo(self.view).with.offset(-ALIGN_WIDTH_PT(15));
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.companyLabel.mas_bottom);
        make.left.equalTo(self.companyLabel.mas_left);
    }];
    
    [self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.iconImg.mas_bottom);
        make.left.equalTo(self.view).with.offset(ALIGN_WIDTH_PT(12));
        make.right.equalTo(self.view).with.offset(-ALIGN_WIDTH_PT(12));
        make.bottom.equalTo(self.view);
    }];
    
}


-(void)loadNet{
    
    [self.manager dispatchTaskWithParam:@{@"id":self.Id} completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
        if (responseObject && [responseObject[@"code"] intValue] == 200){
            
            self.titleLabel.text = responseObject[@"data"][@"title"];
            self.timeLabel.text = responseObject[@"data"][@"createTime"];
            self.companyLabel.text = responseObject[@"data"][@"creatorCompanyName"];
            
            NSString * str = responseObject[@"data"][@"content"];
            NSString * decodeStr = [[str stringByRemovingPercentEncoding] stringByReplacingOccurrencesOfString:@"<p>" withString:@""];
            decodeStr = [decodeStr stringByReplacingOccurrencesOfString:@"</p>" withString:@""];
            self.textView.text = decodeStr;

            
        }else{
            [LUtilityTools showAlertWithTitle:@"温馨提示" message:responseObject[@"msg"] buttonAction:^{
                
            }];
        }
    }];
    
    
    
}



-(HomeShowNewsInfoNetWorking *)manager{
    if (!_manager){
        _manager = [HomeShowNewsInfoNetWorking new];
    }
    return _manager;
}

-(NSMutableDictionary *)paramer{
    if (!_paramer){
        _paramer = [NSMutableDictionary dictionary];
    }
    return _paramer;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel new];
        _titleLabel.font =FONT16;
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.textColor = [UIColor blackColor];
    }
    return _titleLabel;
}

-(UIImageView *)iconImg{
    if (!_iconImg) {
        _iconImg = [UIImageView new];
        _iconImg.image = [UIImage imageNamed:@"移动端logo"];
    }
    return _iconImg;
}

-(UILabel *)companyLabel{
    if (!_companyLabel) {
        _companyLabel = [UILabel new];
        _companyLabel.textAlignment = NSTextAlignmentLeft;
        _companyLabel.font = FONT12;
        _companyLabel.textColor = [UIColor blackColor];
    }
    return  _companyLabel;
}


-(UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel new];
        _timeLabel.font = FONT12;
        _timeLabel.textAlignment = NSTextAlignmentCenter;
        _timeLabel.textColor = [UIColor blackColor];
    }
    return _timeLabel;
}


-(UITextView *)textView{
    if (!_textView){
        _textView = [UITextView new];
        _textView.font = FONT14;
        _textView.textAlignment = NSTextAlignmentLeft;
        _textView.textColor  =[UIColor blackColor];
    }
    return _textView;
}

#pragma mark -- 懒加载






@end
